package lancoo.com.net.retrofitrxjava.network;
import lancoo.com.net.retrofitrxjava.retrofit.JsonRetrofit;
import lancoo.com.net.retrofitrxjava.retrofit.XmlRetrofit;
import retrofit2.Retrofit;

/**
 * Created by pengmi on 2017/9/6.
 */

public class Network {
    public static  String baseUrl ="http://172.16.42.251:7001/";
    public static String flag="defalt";
    public static long serverTime;
    public static long localTime;


    private static Retrofit getInnerRetrofitJson(){
        return JsonRetrofit.getBuilder().baseUrl(baseUrl).build();
    }

    private static Retrofit getInnerRetrofitXml(){
        return XmlRetrofit.getBuilder().baseUrl(baseUrl).build();
    }
    private static Retrofit getInnerRetrofitJson(String url){
        return JsonRetrofit.getBuilder().baseUrl(url).build();
    }

    private static Retrofit getInnerRetrofitXml(String url){
        return XmlRetrofit.getBuilder().baseUrl(url).build();
    }
    public static <T> T getJsonData(Class<T> clazz){
        return getInnerRetrofitJson().create(clazz);
    }
    public static <T> T getXmlData(Class<T> clazz){
        return getInnerRetrofitXml().create(clazz);
    }
    public static <T> T getJsonData(Class<T> clazz,String url){
        return getInnerRetrofitJson(url).create(clazz);
    }
    public static <T> T getXmlData(Class<T> clazz,String url){
        return getInnerRetrofitXml(url).create(clazz);
    }

}
